package com.coms514.scheduleme;

import java.util.Arrays;

import com.google.api.client.util.DateTime;
import com.google.api.services.calendar.model.Event;
import com.google.api.services.calendar.model.EventDateTime;
import com.google.api.services.calendar.model.EventReminder;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

public class EventContentActivity extends Activity {

	  // private final static int ADD_OR_EDIT_EVENT_REQUEST = 1;  // request to create or edit a event
	  private ScheduleMe myState;
	  private Intent t = new Intent();
	  
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_event_content);
		myState = ((ScheduleMe)getApplicationContext());
		t.putExtra("edit_or_show", "show");
		setResult(Activity.RESULT_OK, t); 
		EventInfo eventInfo = myState.eventInfo;
		
		TextView tv1=(TextView) findViewById(R.id.event_summary);     
		tv1.setText("Event Title:\n" + eventInfo.summary); 
		
		TextView tv2=(TextView) findViewById(R.id.event_location);     
		tv2.setText("Location:\n" + eventInfo.location); 
		
		TextView tv3=(TextView) findViewById(R.id.event_start);  

		if (eventInfo.allDayEvent == false) {
			tv3.setText("Start Time:\n" + eventInfo.startDate.dateString + "  " + eventInfo.startTime.timeString); 
		} else
			tv3.setText("Start Time:\n" + eventInfo.startDate.dateString); 
		
		TextView tv4=(TextView) findViewById(R.id.event_end);     
		if (eventInfo.allDayEvent == false)
			tv4.setText("End Time:\n" + eventInfo.endDate.dateString + "  " + eventInfo.endTime.timeString); 
		else
			tv4.setText("End Time:\n" + eventInfo.endDate.dateString); 
		
		TextView tv5=(TextView) findViewById(R.id.event_description);     
		tv5.setText("Description:\n" + eventInfo.description); 
		
		//TextView tv6=(TextView) findViewById(R.id.event_repeation);     
		//tv5.setText("Repeat:\n" + this.getIntent().getStringExtra("frequence") + "; until " + 
		//		this.getIntent().getStringExtra("untilDate") + "  " + this.getIntent().getStringExtra("untilTime")); 
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.event_content, menu);
		return true;
	}

	/*
	@Override
	  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	    super.onActivityResult(requestCode, resultCode, data);
	    switch (requestCode) { 

	      case ADD_OR_EDIT_EVENT_REQUEST:
	    	  if (resultCode == Activity.RESULT_OK) {
	    	  }
	    	  break;
	    }
	  } 
	  */
	
	public void onAddClick(View view) {
		//startAddOrEditEventActivity();
		t.removeExtra("edit_or_show");
		t.putExtra("edit_or_show", "edit");
		setResult(Activity.RESULT_OK, t);   
	    finish();
	}
	
	/*
	private void startAddOrEditEventActivity() {
		// TODO Auto-generated method stub
	    Intent intent = new Intent(this, AddOrEditEventActivity.class);

	    intent.putExtra("add_or_edit", "edit");
	    //intent.putExtra("summary", calendarInfo.summary);
	    startActivityForResult(intent, ADD_OR_EDIT_EVENT_REQUEST);	
	}
	*/

}
